<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>教员登录</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
	<script type="text/javascript">
		function checkLogin(){
			//判断非空
			var tAcc = $("#tAcc").val();
			var pwd = $("#tPwd").val();
			if($.trim(tAcc)==""||$.trim(pwd)==""){
				$("#msg").html("用户名和密码不能为空").css("color","red");
				return false;
			}
			$("#msg").html("");
			
			$.ajax({
				type:"post",
				url:"teacherController/teaLogin.do",
				dataType:"JSON",
				data:{"tAcc":tAcc,"tPassword":pwd},
				//代码执行成功
				success:function(data){
					alert(data);
					if(data==1){
						//登陆成功 去查询所有
						//location.href="/WebRoot/WEB-INF/myjsp/teaCore.jsp";
						alert("登录成功");
					}else{
						//登录失败
						$("#msg").html("用户名与密码不匹配，请重新输入").css("color","red");
					}
				},
				//代码执行失败
				error:function(){
					alert("警告：系统异常！！！")
				}
			});
		}
	</script>

  </head>
  
  <body>
  	<h3>欢迎登录XXX家教网</h3>
  		<span id="msg"></span><br>
    	用户名:<input type = "text" name = "tAcc" id="tAcc"><br>
    	密码:<input type = "password" name = "tPassword" id="tPwd"><br>
    	<input type = "button" value = "登录" onclick="checkLogin()"/><br>
    	<a href = "teacherController/toAddJsp.do">注册教员</a>
  </body>
</html>
